<template>
    <!--列表-->
    <div class="list-container">
        <div class="sortList clearfix">
            <div class="center">
                <!--banner轮播-->
                <div class="swiper-container" id="mySwiper">
                    <div class="swiper-wrapper">
                        <div class="swiper-slide">
                            <el-carousel height="450px">
                                <el-carousel-item v-for="(item, index) in images" :key="index">
                                    <img :src="item.url" alt="alt"/>
                                </el-carousel-item>
                            </el-carousel>
                        </div>
                    </div>
                    <!-- 如果需要分页器 -->
                    <div class="swiper-pagination"></div>

                    <!-- 如果需要导航按钮 -->
                    <div class="swiper-button-prev"></div>
                    <div class="swiper-button-next"></div>
                </div>
            </div>
            <div class="right">
                <div class="news">
                    <h4>
                        <em class="fl" >好未来快报<i class="el-icon-edit"></i></em>
                        <span class="fr tip"></span>
                    </h4>
                    <div class="clearix" v-for="item in page.records" :key="item.id">
                        <ul class="news-list unstyled">
                            <li>
                                <span class="bold" v-html="item.noticeTip">{{item.noticeTip}}</span>
                                <span class="bold">({{item.modifiedTime| formatDate}})</span>
                                <div></div>
                                {{item.noticeMessage}}
                                <div class="tableTitle"></div>
                            </li>
                        </ul>
                    </div>

                    <el-pagination
                            small
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="page.current"
                            :page-size="page.size"
                            layout="total, prev, pager, next"
                            :total="page.total">
                    </el-pagination>
                </div>
                <!--                <ul class="lifeservices">-->
                <!--                    <li class=" life-item ">-->
                <!--                        <i class="list-item"></i>-->
                <!--                        <span class="service-intro">话费</span>-->
                <!--                    </li>-->
                <!--                    <li class=" life-item ">-->
                <!--                        <i class="list-item"></i>-->
                <!--                        <span class="service-intro">机票</span>-->
                <!--                    </li>-->
                <!--                    <li class=" life-item ">-->
                <!--                        <i class="list-item"></i>-->
                <!--                        <span class="service-intro">电影票</span>-->
                <!--                    </li>-->
                <!--                    <li class=" life-item ">-->
                <!--                        <i class="list-item"></i>-->
                <!--                        <span class="service-intro">游戏</span>-->
                <!--                    </li>-->
                <!--                    <li class=" life-item">-->
                <!--                        <i class="list-item"></i>-->
                <!--                        <span class="service-intro">彩票</span>-->
                <!--                    </li>-->
                <!--                    <li class=" life-item">-->
                <!--                        <i class="list-item"></i>-->
                <!--                        <span class="service-intro">加油站</span>-->
                <!--                    </li>-->
                <!--                    <li class=" life-item">-->
                <!--                        <i class="list-item"></i>-->
                <!--                        <span class="service-intro">酒店</span>-->
                <!--                    </li>-->
                <!--                    <li class=" life-item">-->
                <!--                        <i class="list-item"></i>-->
                <!--                        <span class="service-intro">火车票</span>-->
                <!--                    </li>-->
                <!--                    <li class=" life-item ">-->
                <!--                        <i class="list-item"></i>-->
                <!--                        <span class="service-intro">众筹</span>-->
                <!--                    </li>-->
                <!--                    <li class=" life-item">-->
                <!--                        <i class="list-item"></i>-->
                <!--                        <span class="service-intro">理财</span>-->
                <!--                    </li>-->
                <!--                    <li class=" life-item">-->
                <!--                        <i class="list-item"></i>-->
                <!--                        <span class="service-intro">礼品卡</span>-->
                <!--                    </li>-->
                <!--                    <li class=" life-item">-->
                <!--                        <i class="list-item"></i>-->
                <!--                        <span class="service-intro">白条</span>-->
                <!--                    </li>-->
                <!--                </ul>-->
                <div class="ads">
                    <img src="../../assets/images/ad1.jpeg"/>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import {getNoticePage} from '@/api/index'

    export default {
        name: "ListContainer",
        data() {
            return {
                images: [{
                    url: require('../../assets/images/banner1.jpeg')
                }, {
                    url: require('../../assets/images/banner2.jpeg')
                }, {
                    url: require('../../assets/images/banner3.jpeg')
                }, {
                    url: require('../../assets/images/banner4.jpeg')
                }],
                page: {
                    records: [],
                    total: 0,
                    size: 0,
                    current: 0,
                    orders: []
                },
                pageNum: 1,
                pageSize: 3,
            }
        },
        created() {
            this.getNotice()
        },
        filters: {
            formatDate: function (value) {
                let date = new Date(value);
                let y = date.getFullYear();
                let MM = date.getMonth() + 1;
                MM = MM < 10 ? ('0' + MM) : MM;
                let d = date.getDate();
                d = d < 10 ? ('0' + d) : d;
                let h = date.getHours();
                h = h < 10 ? ('0' + h) : h;
                let m = date.getMinutes();
                m = m < 10 ? ('0' + m) : m;
                let s = date.getSeconds();
                s = s < 10 ? ('0' + s) : s;
                return y + '年' + MM + '月' + d + '日' + h + '时' + m + '分';
            }
        },
        methods: {
            getNotice() {
                getNoticePage(this.pageNum, this.pageSize).then(response => {
                    this.page = response.data;
                })
            },
            handleSizeChange(val) {
                /* 将value赋值给size, 重新查询数据 */
                this.pageSize = val
                this.onSubmit()
            },
            handleCurrentChange(val) {
                this.pageNum = val
                this.onSubmit()
            },
            onSubmit() {
                getNoticePage(this.pageNum, this.pageSize).then(response => {
                    this.page = response.data
                })
            },
        }
    }
</script>

<style scoped lang="less">
    .tableTitle {
        position: relative;
        margin: 0 auto;
        width: 230px;
        height: 1px;
        background-color: #d4d4d4;
        text-align: center;
        font-size: 16px;
        color: rgba(101, 100, 101, 1);
    }
    .el-carousel__item h3 {
        color: #475669;
        font-size: 14px;
        opacity: 0.75;
        line-height: 150px;
        margin: 0;
    }

    .el-carousel__item:nth-child(2n) {
        background-color: #99a9bf;
    }

    .el-carousel__item:nth-child(2n+1) {
        background-color: #d3dce6;
    }

    .list-container {
        width: 1200px;
        height: 500px;
        margin: 0 auto;

        .sortList {
            height: 464px;
            padding-left: 210px;

            .center {
                box-sizing: border-box;
                width: 740px;
                height: 100%;
                padding: 5px;
                float: left;
            }

            .right {
                float: left;
                width: 250px;
                height: 500px;
                background-color: white;

                .news {
                    border: 1px solid #e4e4e4;
                    margin-top: 5px;

                    h4 {
                        border-bottom: 1px solid #e4e4e4;
                        padding: 5px 10px;
                        margin: 5px 5px 0;
                        line-height: 22px;
                        overflow: hidden;
                        font-size: 14px;

                        .fl {
                            float: left;
                        }

                        .fr {
                            float: right;
                            font-size: 12px;
                            font-weight: 400;
                        }
                    }

                    .news-list {
                        padding: 1px 15px;
                        line-height: 20px;

                        .bold {
                            color: #df3033;
                            font-weight: 900;
                        }
                    }
                }

                .lifeservices {
                    border-right: 1px solid #e4e4e4;
                    overflow: hidden;
                    display: flex;
                    flex-wrap: wrap;

                    .life-item {
                        border-left: 1px solid #e4e4e4;
                        border-bottom: 1px solid #e4e4e4;
                        margin-right: -1px;
                        height: 64px;
                        text-align: center;
                        position: relative;
                        cursor: pointer;
                        width: 25%;

                        .list-item {
                            background-image: url(../../assets/images/icons.png);
                            width: 61px;
                            height: 40px;
                            display: block;
                        }

                        .service-intro {
                            line-height: 22px;
                            width: 60px;
                            display: block;
                        }

                        &:nth-child(1) {
                            .list-item {
                                background-position: 0px -5px;
                            }
                        }

                        &:nth-child(2) {
                            .list-item {
                                background-position: -62px -5px;
                            }
                        }

                        &:nth-child(3) {
                            .list-item {
                                background-position: -126px -5px;
                            }
                        }

                        &:nth-child(4) {
                            .list-item {
                                background-position: -190px -5px;
                            }
                        }

                        &:nth-child(5) {
                            .list-item {
                                background-position: 0px -76px;
                            }
                        }

                        &:nth-child(6) {
                            .list-item {
                                background-position: -62px -76px;
                            }
                        }

                        &:nth-child(7) {
                            .list-item {
                                background-position: -126px -76px;
                            }
                        }

                        &:nth-child(8) {
                            .list-item {
                                background-position: -190px -76px;
                            }
                        }

                        &:nth-child(9) {
                            .list-item {
                                background-position: 0px -146px;
                            }
                        }

                        &:nth-child(10) {
                            .list-item {
                                background-position: -62px -146px;
                            }
                        }

                        &:nth-child(11) {
                            .list-item {
                                background-position: -126px -146px;
                            }
                        }

                        &:nth-child(12) {
                            .list-item {
                                background-position: -190px -146px;
                            }
                        }
                    }
                }

                .ads {
                    margin-top: 5px;

                    img {
                        opacity: 0.8;
                        transition: all 400ms;

                        &:hover {
                            opacity: 1;
                        }
                    }
                }
            }
        }
    }
</style>
